import java.io.*;
public class Main {
	static int hex2dec(String hex) throws Exception {
		hex = hex.toUpperCase();
		int dec = 0;
		for (int i = 0; i < hex.length(); i++) {
			char c = hex.charAt(i);
			int digit = 0;
			if ('0' <= c && c <= '9')
				digit = c - '0';
			else if ('A' <= c && c <= 'F') {
				digit = c - 'A' + 10;
			}
			else {
				throw new Exception();
			}
			dec = dec * 16 + digit;								
		}
		return dec;			
	}	
	public static void main(String[] args) {
		System.out.println("请输入一个十六进制数：");
		String hex;
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			hex = in.readLine();
			System.out.println(hex2dec(hex));							
		} catch (IOException e) {			
		} catch (Exception e) {
			System.out.println("format error");			
		}	
	}
}
